import { InjectionKey } from 'vue'
import { createStore, Store, useStore as baseUseStore } from 'vuex'
import state, { RooterState } from './state'
import getters from './getters'
import mutations from './mutations'
import actions from './actions'

// 定义 injection key
export const key: InjectionKey<Store<RooterState>> = Symbol('vue-store')

export default createStore<RooterState>({
  state,
  getters,
  mutations,
  actions
})

export function useStore () {
  return baseUseStore(key)
}
